package com.shrct.businessprocess.budget.impl;

import com.shrct.businessprocess.budget.RCCostBreakDown;
import com.shrct.businessprocess.budget.RCHasCostBudget;
import com.shrct.businessprocess.budget.RCHasCostBudgetCostRequest;
import com.shrct.businessprocess.budget.impl.RCHasCostBudgetImpl;
import com.shrct.businessprocess.budget.proxy.RCHasCostBudgetCostRequestProxy;
import com.shrct.businessprocess.project.RCExchangeRate;
import com.shrct.businessprocess.project.RCProject;
import com.shrct.businessprocess.purchase.impl.RCPayRequestImpl;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCHASCOSTBUDGETCOSTREQUEST_TYPE")
public class RCHasCostBudgetCostRequestImpl extends RCPayRequestImpl implements RCHasCostBudgetCostRequest {
  public RCHasCostBudgetCostRequestImpl() {
    super();
  }
  
  public RCHasCostBudgetCostRequestImpl(final RCHasCostBudget budget) {
    super();
    this.budget = budget;
  }
  
  @JoinColumn(name = "budget_id")
  @ManyToOne(targetEntity = RCHasCostBudgetImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCHasCostBudget budget;
  
  public RCHasCostBudget getBudget() {
    return this.budget;
  }
  
  public RCHasCostBudgetCostRequest setBudget(final RCHasCostBudget budget) {
    this.budget = budget;
    return this;			
    
  }
  
  private Double taxRate;
  
  public Double getTaxRate() {
    return this.taxRate;
  }
  
  public RCHasCostBudgetCostRequest setTaxRate(final Double taxRate) {
    this.taxRate = taxRate;
    return this;			
    
  }
  
  public RCExchangeRate getDefaultExchangeRate() {
    RCCostBreakDown _cbd = this.budget.getCbd();
    RCProject _project = _cbd.getProject();
    RCExchangeRate _defaultExchangeRate = _project.getDefaultExchangeRate();
    return _defaultExchangeRate;
  }
  
  public String getEntityName() {
    String _entityName = this.budget.getEntityName();
    return _entityName;
  }
  
  public static RCHasCostBudgetCostRequest create(final RCHasCostBudget budget, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.budget.RCHasCostBudgetCostRequest rCHasCostBudgetCostRequest = new com.shrct.businessprocess.budget.impl.RCHasCostBudgetCostRequestImpl(
    	budget
    );
    objectFactory.create(rCHasCostBudgetCostRequest);
    return rCHasCostBudgetCostRequest;			
    
  }
  
  public static RCHasCostBudgetCostRequest createRCHasCostBudgetCostRequestImpl(final RCHasCostBudget budget, final IObjectFactory objectFactory, final Procedure1<RCHasCostBudgetCostRequest> init) {
    com.shrct.businessprocess.budget.RCHasCostBudgetCostRequest rCHasCostBudgetCostRequest = new com.shrct.businessprocess.budget.impl.RCHasCostBudgetCostRequestImpl(
    	budget
    );
    objectFactory.create(rCHasCostBudgetCostRequest);
    init.apply(rCHasCostBudgetCostRequest);
    
    return rCHasCostBudgetCostRequest;			
    
  }
  
  public RCHasCostBudgetCostRequestProxy toProxy() {
    com.shrct.businessprocess.budget.proxy.RCHasCostBudgetCostRequestProxy proxy = new com.shrct.businessprocess.budget.proxy.RCHasCostBudgetCostRequestProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
